/*3:
用户输入任意一个整数，求其所有位上的数字和并输出
比如123，和为6,10000和为1,用for完成*/

package ZUOYE0421;

import java.util.Scanner;

public class 作业三 {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		System.out.println("输入一个数：");
		int num = in.nextInt();
		int gewei = num % 10;
		int b = 0, b1 = 0;
		for (int a = 1;;) {
			num = num / 10;
			b = num % 10;
			b1 = b1 + b;
			if (num % 10 == num) {
				break;
			}
		}
		System.out.println("和为：" + (b1 + gewei));
	}
}
